package som.swj;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
import som.swj.config.LoadBalancerConfig;

@SpringBootApplication
@LoadBalancerClient(name = "quickstart-provider",
                    configuration = LoadBalancerConfig.class)
public class NacosConsumerApp {

    public static void main(String[] args) {
        SpringApplication.run(NacosConsumerApp.class,args);
    }

    @Bean
    //Spring Cloud提供了@LoadBalanced注解用于开启RestTemplate的客户端负载均衡功能
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

}
